package ink.ykb.demo.permission.dao;
import java.util.List;

import org.beetl.sql.core.annotatoin.Sql;
import org.beetl.sql.core.mapper.BaseMapper;

import ink.ykb.demo.permission.entity.Rule;

public interface RuleDao extends BaseMapper<Rule> {
  
  
  
  /**
   * 根据id获取权限
   * @param id
   * @return
   */
  @Sql("select * from rule where id = ?")
  Rule getRuleById(Long id);

  /**
   * 根据code获取权限
   * @param code
   * @return
   */
  @Sql("select * from rule where code = ?")
  Rule getRuleByCode(String code);
  
  /**
   * 根据code获取权限(加锁)
   * @param code
   * @return
   */
  @Sql("select * from rule where code = ? for update")
  Rule getRuleAndLock(String code);

  /**
   * 根据类型查询所有权限
   * @return
   */
  @Sql("select * from rule where type = ?")
  List<Rule> getRuleList(Integer type);
  
  /**
   * 查询所有权限
   * @return
   */
  @Sql("select * from rule")
  List<Rule> getRuleList();
  
  /**
   * 查询所有权限
   * @return
   */
  @Sql("select * from rule where parent_id = ?")
  List<Rule> getRuleListByParentId(Long parentId);
	
}